# 一键修复所有问题
sed -i.bak '1s/.*/from routers import auth_api, erp_api, tasks_api, dashboard_api, uniapp_goods_api, wangdian_api/' main.py && \
mkdir -p util && \
echo '# Util package' > util/__init__.py && \
cat > util/response_util.py << 'EOF'
# -*- coding: utf-8 -*-
"""
响应工具类
"""
from typing import Any, Dict, Optional
from datetime import datetime

class ResponseUtil:
    """统一响应格式工具类"""
    
    @staticmethod
    def success(data: Any = None, message: str = "操作成功", code: int = 200) -> Dict[str, Any]:
        """成功响应"""
        return {
            "code": code,
            "message": message,
            "data": data,
            "timestamp": datetime.now().isoformat(),
            "success": True
        }
    
    @staticmethod
    def error(message: str = "操作失败", code: int = 500, data: Any = None) -> Dict[str, Any]:
        """错误响应"""
        return {
            "code": code,
            "message": message,
            "data": data,
            "timestamp": datetime.now().isoformat(),
            "success": False
        }
    
    @staticmethod
    def paginate(data: list, total: int, page: int = 1, page_size: int = 10, 
                message: str = "查询成功") -> Dict[str, Any]:
        """分页响应"""
        return {
            "code": 200,
            "message": message,
            "data": {
                "list": data,
                "pagination": {
                    "total": total,
                    "page": page,
                    "page_size": page_size,
                    "total_pages": (total + page_size - 1) // page_size
                }
            },
            "timestamp": datetime.now().isoformat(),
            "success": True
        }
    
    @staticmethod
    def unauthorized(message: str = "未授权访问") -> Dict[str, Any]:
        return ResponseUtil.error(message=message, code=401)
    
    @staticmethod
    def forbidden(message: str = "访问被禁止") -> Dict[str, Any]:
        return ResponseUtil.error(message=message, code=403)
    
    @staticmethod
    def not_found(message: str = "资源不存在") -> Dict[str, Any]:
        return ResponseUtil.error(message=message, code=404)
    
    @staticmethod
    def bad_request(message: str = "请求参数错误") -> Dict[str, Any]:
        return ResponseUtil.error(message=message, code=400)
EOF
echo "✅ 修复完成，重新启动项目..." && \
python run.py